package com.gouda.core.service.impl.merchantManager;

import com.gouda.core.dao.MerchantWalletDao;
import com.gouda.core.dto.merchantManage.MerchantWalletDto;
import com.gouda.core.entity.MerchantWalletEntity;
import com.gouda.core.service.BaseService;
import com.gouda.core.service.merchantManage.MerchantWalletService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * Created by KGL on 2015/12/7.
 */
@Service
public class MerchantWalletServiceImpl extends BaseService implements MerchantWalletService {
    @Autowired
    private MerchantWalletDao merchantWalletDao;

    @Override
    public boolean createMerchantWallet(final long merchantId) {
        MerchantWalletEntity merchantWalletEntity = ENTITY_FACTORY.generateDBEntity(MerchantWalletEntity.class);
        merchantWalletEntity.setId(merchantId);
        merchantWalletEntity.setBalance(0l);
        merchantWalletEntity.setTotalPrice(0l);
        merchantWalletEntity.setWithdrawTotalPrice(0l);
        merchantWalletEntity.setCreateTime(new Date());
        return merchantWalletDao.insert(merchantWalletEntity);
    }
}
